<?php
class Clound_String
{
    /**
     * Unique id of Role
     *
     * @var string
     */
    protected $_string;

    /**
     * Sets the Role identifier
     *
     * @param  string $id
     * @return void
     */
    public function __construct()
    {
        //$this->_string = (string) $string;
    }

    /**
     * Defined by Zend_Acl_Role_Interface; returns the Role identifier
     *
     * @return string
     */
    public function getRoleId()
    {
        return $this->_roleId;
    }

    public static function _restoreXmlBadChar($pshtml){
        $pshtml = str_replace('&amp;','&',$pshtml);
        $pshtml = str_replace('&quot;','"',$pshtml);
        $pshtml = str_replace('&#39;',"'",$pshtml);
        $pshtml = str_replace('&lt;','<',$pshtml);
        $pshtml = str_replace('&gt;','>',$pshtml);
        $pshtml = str_replace('&#34;','"',$pshtml);
        // $pshtml = htmlspecialchars($pshtml);
        return $pshtml;
    }
   
    public function registerScriptFile($dir){
        $post_header = '<script type="text/javascript" src="'.$dir.'"></script>';
        return $post_header;
    }
    public function registerCssFile($dir){
        $post_header = '<link type="text/css" href="'.$dir.'"></link>';
        return $post_header;
    }
    public static function registerFile($data){
        $iTotal = sizeof($data);
        $post_header ='';
        for ($i=0; $i < $iTotal; $i++) { 
            if($data[$i][1] =='js')
                $post_header .= '<script type="text/javascript" src="'.$data[$i][0].'"></script>';
            else
                $post_header .= '<link rel="stylesheet" type="text/css" href="'.$data[$i][0].'"></link>';
        }
        return $post_header;
    }

    public static function _generateSelectOption($arr_list,$IdColumn,$ValueColumn,$NameColumn,$SelectedValue,$multi = false){
        $strHTML = "";
        $i=0;
        $count=sizeof($arr_list);
        for($row_index = 0;$row_index< $count;$row_index++){
            $strID=trim($arr_list[$row_index][$IdColumn]);
            $strValue=trim($arr_list[$row_index][$ValueColumn]);
            $gt=$SelectedValue;
            $optSelected = self::checkSelect($SelectedValue,$strValue);
            $DspColumn=trim($arr_list[$row_index][$NameColumn]);
            $strHTML.='<option id='.'"'.$strID.'"'.' '.'name='.'"'.$DspColumn.'"'.' ';
            $strHTML.='value='.'"'.$strValue.'"'.' '.$optSelected.'>'.$DspColumn.'</option>';
            $i++;
        }
        return $strHTML;
    }

    public static function checkSelect($SelectedValue,$strValue){
        if(!is_array($SelectedValue)){
            $arrSelected = explode(',', $SelectedValue);
            foreach ($arrSelected as $key => $value) {
                if($strValue == $value){
                    return "selected";
                }
            }
        }
        return "";
    }

    public static function _addEmptyRow($iCurrentRow,$iTotalRow,$iTotalColumn) {             
        
        if($iCurrentRow>=$iTotalRow) {
            return '';
        }
        $sHtml = '';
        for($i = $iCurrentRow+1; $i <=$iTotalRow; $i ++) {
            $sHtml .= '<tr>';
            for($j=1; $j<=$iTotalColumn; $j++) {       
                $sHtml.= '<td>&nbsp;</td>';
            }
            $sHtml .= '</tr>';
        }
        return $sHtml;
    }
}